function sum(a, b) {
	return a + b
}

// function currySum(sum) {
// 	return function (a) {
// 		return function (b) {
// 			return sum(a, b)
// 		}
// 	}
// }

function currySum(func) {
	return function curried(...args) {
		console.log(args.length, ' ', func.length)
		// 柯里化函数参数个数>=原函数参数个数，直接调用原函数返回结果
		if (args.length >= func.length) {
			return func(...args)
		}else{
            return function(...args2){
                let arg = [...args,...args2]
                return curried(...arg)
            }
        }
	}
}

let f = currySum(sum)
let s = f(10)(20)
console.log(s)
